package com.bjpowernode.crm.workbench.service.impl;

import com.bjpowernode.crm.commons.utils.DateUtils;
import com.bjpowernode.crm.commons.utils.UUIDUtils;
import com.bjpowernode.crm.workbench.domain.Contacts;
import com.bjpowernode.crm.workbench.mapper.ContactsMapper;
import com.bjpowernode.crm.workbench.service.ContactsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

/**
 * 郭俊才
 * 2021/8/30
 */
@Service
public class ContactsServiceImpl implements ContactsService {
    @Autowired
    private ContactsMapper contactsMapper;
    @Override
    public int saveSelective(Contacts record) {
        //设置主键
        record.setId(UUIDUtils.getUUID());
        //设置创建时间
        record.setCreateTime(DateUtils.formatDateTime(new Date()));
        return contactsMapper.insertSelective(record);
    }

    @Override
    public int removeByPrimaryKey(String id) {
        return contactsMapper.deleteByPrimaryKey(id);
    }

    @Override
    public int editByPrimaryKeySelective(Contacts record) {
        //设置修改时间
        record.setEditTime(DateUtils.formatDateTime(new Date()));
        return contactsMapper.updateByPrimaryKeySelective(record);
    }

    @Override
    public Contacts queryByPrimaryKey(String id) {
        return contactsMapper.selectByPrimaryKey(id);
    }

    @Override
    public List<Contacts> queryAllByCondition(Contacts contacts) {
        return contactsMapper.selectAllByCondition(contacts);
    }

    @Override
    public Contacts queryByPrimaryKeyForDetails(String id) {
        return contactsMapper.selectByPrimaryKeyForDetails(id);
    }

    @Override
    public List<Contacts> queryByName(String fullName) {
        return contactsMapper.selectByName(fullName);
    }
}
